<template>
  <div class="order-manage">
    <van-nav-bar title="订单管理" />
    <van-tabs v-model:active="active">
      <van-tab title="发货" name="1"></van-tab>
      <van-tab title="配送" name="2"></van-tab>
    </van-tabs>
    <van-card v-for="item in userStore.OrderList" :key="item._id" :num="item.goodsNumber" :price="item.price"  :title="item.goodsName"
      :thumb="item.goodsthumb" v-show="active == item.statu" >
      <template #tags>
        <van-tag plain type="primary">{{ orderStatu[item.statu] }}</van-tag>
      </template>

      <template #footer>
        <van-button @click="upStatu(item._id,item.statu)" size="small">{{ butStatu[item.statu] }}</van-button>
      </template>
    </van-card>
  </div>
</template>

<script setup lang="ts">
  import { postOrderDate } from '../api';
  import { useUserStore } from '../store';

  const userStore = useUserStore();
  userStore.getOrderList();
  let active = ref(2);

  let orderStatu = [
    "",
    "待发货",
    "待配送",
  ]

  let butStatu = [
    "",
    "发货",
    "送达"
  ]

  let upStatu = async (_id:string,statu: number)=>{
  statu++;
  let result = await postOrderDate({
    status: "change",
    _id: _id,
    statu: statu
  })
  userStore.getOrderList();
}

</script>

<style scoped>

</style>
